package com.xiaoyu.im

import `in`.srain.cube.util.StringUtil
import android.text.TextUtils
import com.xiaoyu.im.datamodel.IMOnlineStatus

object IMUtil {

    @JvmStatic
    fun vendorCidToUid(vendorCid: String): String {
        val parts = StringUtil.blankIfNull(vendorCid).split("_".toRegex(), 2)
        return StringUtil.blankIfNull(parts.lastOrNull())
    }

    @JvmStatic
    fun isOnline(onlineStatus: String?): Boolean {
        return TextUtils.equals(onlineStatus, IMOnlineStatus.LOGINED)
    }

    @JvmStatic
    fun shouldNotLogin(onlineStatus: String?): Boolean {
        return (TextUtils.equals(onlineStatus, IMOnlineStatus.LOGINED)
                || TextUtils.equals(onlineStatus, IMOnlineStatus.CONNECTING)
                || TextUtils.equals(onlineStatus, IMOnlineStatus.LOGINING))
    }
}